#ifndef _EPTHREADPOOL_H_
#define _EPTHREADPOOL_H_

#include <pthread.h>
#include <unistd.h>
#include <list>
#include "m_thread_cond.h"

using namespace std;

class Task{
 public:
	Task(){}
 	virtual int run()=0;

};

typedef list<Task *> list_task;

class E_PThread_Pool{
    public:
	E_PThread_Pool(unsigned int max=10,\
	unsigned int min=10,long wait=200);
	~E_PThread_Pool();
	void addTask(Task *task);
	unsigned int runcount;

     private:
	static void* taskThread(void *arg);
	void createThread();
	void destroyThread();
	
	unsigned int maxcount;
	unsigned int mincount;
	unsigned int count;
	unsigned int waitcount;
	long waitsec;
	list_task taskList;
	m_cond taskCond;
	m_cond cond;
	bool Stop;
};


#endif//_EPTHREADPOOL_H_
